package utils

import (
	"gopkg.in/gomail.v2"
	"os"
)

func SendMail(to, subject, body string) error {
	
	email := os.Getenv("QQ_EMAIL")
	password := os.Getenv("QQ_EMAIL_PASS")
	m := gomail.NewMessage()
	m.SetHeader("From", email)
	m.SetHeader("To", to)
	m.SetHeader("Subject", subject)
	m.SetBody("text/html", body)

	d := gomail.NewDialer("smtp.qq.com", 587, email, password)
	return d.DialAndSend(m)
}
